package com.tiancheng.trade.commom.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author: kellen
 * @Description: 清分规则类型
 * @Date: create in 2024/12/5 15:36
 */
@Getter
@AllArgsConstructor
public enum SettleRuleTypeEnums implements BaseEnum<String> {

    merchant("M", "商户清分规则"),
    product("P", "商品清分规则"),
    ;

    private final String code;
    private final String msg;

    public static Optional<SettleRuleTypeEnums> getByRuleCode(String ruleCode){
        return Arrays.stream(SettleRuleTypeEnums.values()).filter(s->ruleCode.startsWith(s.getCode())).findFirst();
    }
}
